<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""DTD/xhtml1-strict.dtd">
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%@taglib uri="/WEB-INF/fmt.tld" prefix="fmt"%>
<%@taglib uri="/WEB-INF/el.tld" prefix="el"%>
<%@taglib uri="/WEB-INF/fn.tld" prefix="fn"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title></title>
		<c:import url="/includes/css_inc.jsp"/>
		<c:import url="/includes/js_inc.jsp"/>
		<script>
			$(function() {
				$("#search").button({
		            icons: {
		                primary: "ui-icon-search"
		            }
		        }).click(function(){
		        	if (validateEmpty()) {
		        		$("#searchForm").submit();
		        	}
		        });
				$("#upload").button({
		            icons: {
		                primary: "ui-icon-arrowthickstop-1-n"
		            }
		        }).click(function(){
		        	$("#job").val("upload");
		        	$("#searchForm").submit();
		        });
			/* 	$("[name=balanceAmount]").blur(function(){
					
				}); */
		        thaiDatepicker("suspendDate","#","1");
			});
			function setAreaCode(v) {
				document.getElementById("areaCode").value = v;
			}
			function showArea(v, mode) {
				if (v == "2") {
					document.getElementById("nhsoZone").style.display = "inline";
					document.getElementById("province").style.display = "none";
					if (mode == 1){
						document.getElementById("nhsoZone").value = " ";
					}
				} else if (v == "3") {
					document.getElementById("province").style.display = "inline";
					document.getElementById("nhsoZone").style.display = "none";
					if (mode == 1){
						document.getElementById("province").value = " ";
					}
				} else {
					document.getElementById("nhsoZone").style.display = "none";
					document.getElementById("province").style.display = "none";
				}
			}
			
		</script>
	</head>
	<body>
		<c:set var="auth" value="${el:getMapValue(menuAuth, 'ACC60405')}"/>
		<c:import url="/apps/msg.jsp"/>
		<form class="acc67-form" name="searchForm" id="searchForm" action="${pageContext.request.contextPath}/acc6" method="post">
		<input type="hidden" name="app" id="app" value="ACC60108"/>
		<input type="hidden" name="job" id="job" value="${job}"/>
		<table width="100%" class="ui-widget ui-widget-content" border="0">
			<tr>
				<th align="left" class="acc67-header ui-widget-header" colspan="2"><b>${screenCode.ACC60405}</b></th>
			</tr>
			<tr>
				<td class="bold"  width="15%">จังหวัด : </td>
				<td>
					<c:if test="${userInfo.areaLevel != 2}" >
						<select name="areaLevel" id="areaLevel" onchange="showArea(this.value);">
						<option value="">--- กรุณาเลือกข้อมูล ---</option>
						<c:forEach var="al" items="${areaLevel}">
							<c:if var="selected" test="${user.areaLevel == al.key}" />
							<option value="${al.key}" ${selected ? 'selected' : ''}>${al.key == '1' ? 'เลือกทั้งหมด' : al.value}</option>
					    </c:forEach>
					    </select>
					    <select name="nhsoZone" id="nhsoZone" style="display: none;" onchange="setAreaCode(this.value,'1');">
						<option value="">--- กรุณาเลือกข้อมูล ---</option>
						<c:forEach var="nhsoZone" items="${lsNhsoZone}">
							<c:if var="selected" test="${user.areaCode == nhsoZone.NHSO_ZONE}" />
							<option value="${nhsoZone.NHSO_ZONE}" ${selected ? 'selected' : ''}>${nhsoZone.NHSO_ZONENAME}</option>
					    </c:forEach>
					    </select>
					    <select name="province" id="province" style="display: none;" onchange="setAreaCode(this.value,'1');">
						<option value="">--- กรุณาเลือกข้อมูล ---</option>
						<c:forEach var="province" items="${lsProvince}">
							<c:if var="selected" test="${user.areaCode == province.PROVINCE_ID}" />
							<option value="${province.PROVINCE_ID}" ${selected ? 'selected' : ''}>${province.PROVINCE_NAME}</option>
					    </c:forEach>
					    </select>
				    	<script>showArea("${user.areaLevel}","0");</script>
					</c:if>
					<c:if test="${userInfo.areaLevel == 2}">
						<input type="hidden" name="areaLevel" id="areaLevel" value="3"/>
					    <select name="areaCode" id="areaCode">
						<option value="">--- กรุณาเลือกข้อมูล ---</option>
						<c:forEach var="province" items="${lsProvince}">
							<c:if var="selected" test="${user.areaCode == province.PROVINCE_ID}" />
							<option value="${province.PROVINCE_ID}" ${selected ? 'selected' : ''}>${province.PROVINCE_NAME}</option>
					    </c:forEach>
					    </select>
					</c:if>
				    <span class="red" id="$areaLevel">*</span>
				</td>
			</tr>
			<tr>
				<td class="bold">ยอดเงิน ณ วันที่ : </td>
				<td>
					<input type="text" name="suspendDate" id="suspendDate" readonly="readonly" size="12" maxlength="10" onkeypress="return numberAndSlash(event);" onblur="dateFormat(this);"/>
					<span id="#suspendDate" class="red">*</span>
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<c:if test="${fn:contains(auth, 'S')}">
						<button id="search" type="button" class="acc67-button">ค้นหาข้อมูล</button>
						<button id="upload" type="button" class="acc67-button">upload</button>
					</c:if>
				</td>
			</tr>
		</table>
		</form>
	</body>
</html>